package com.atguigu.guli.edu.service.impl;

import com.atguigu.common_utils.utils.PageUtils;
import com.atguigu.common_utils.utils.Query;
import com.atguigu.guli.edu.entity.Chapter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.atguigu.guli.edu.dao.EduChapterDao;
import com.atguigu.guli.edu.service.EduChapterService;

import javax.print.DocFlavor;


@Service("eduChapterService")
public class EduChapterServiceImpl extends ServiceImpl<EduChapterDao, Chapter> implements EduChapterService {

    @Autowired
    EduChapterDao chapterDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<Chapter> page = this.page(
                new Query<Chapter>().getPage(params),
                new QueryWrapper<Chapter>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<Chapter> queryPage(String courseId) {

        List<Chapter> chapters = chapterDao.queryChapterAndVideo(courseId);
        return chapters;
    }

}